package com.xtpt.disaster.service.impl;

import com.xtpt.disaster.bean.JobDetail;
import com.xtpt.disaster.common.PortalResult;
import com.xtpt.disaster.mapper.JobDetailMapper;
import com.xtpt.disaster.service.DBMysqlJobDetailService;
import com.xtpt.disaster.service.JobDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DBMysqlJobDetailServiceImpl implements DBMysqlJobDetailService {

    @Autowired
    JobDetailMapper jobDetailMapper;

    @Autowired
    JobDetailService jobDetailService;

    @Override
    public int deleteByPrimaryKey(Long jobId) {
        return jobDetailMapper.deleteByPrimaryKey(jobId);
    }

    @Override
    public int insert(JobDetail record) {
        return jobDetailMapper.insert(record);
    }

    @Override
    public int insertOrUpdate(JobDetail record) {
        JobDetail j= jobDetailMapper.selectByPrimaryKey(record.getJobId());
        if(j!=null && j.getJobId().equals(record.getJobId()))
        {
            return jobDetailMapper.updateByPrimaryKeySelective(record);
        }
        return jobDetailMapper.insert(record);
    }

    @Override
    public PortalResult insertSelective(JobDetail record) {
        return jobDetailService.insert(record);
    }

    @Override
    public JobDetail selectByPrimaryKey(Long jobId) {
       return jobDetailMapper.selectByPrimaryKey(jobId);
    }

    @Override
    public int updateByPrimaryKeySelective(JobDetail record) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(JobDetail record) {
        return 0;
    }

    @Override
    public List<JobDetail> selectJobByCon(JobDetail jobDetail) {
        return jobDetailService.getJobs(jobDetail);
    }

    @Override
    public List<JobDetail> selectAllJobDetail() {
        return jobDetailMapper.selectAllJobDetail();
    }
}
